//
//  YKRabbitMQSDKDemoViewController.m
//  YKRabbitMQSDK
//
//  Created by edward on 2022/10/10.
//

#import "YKRabbitMQSDKDemoViewController.h"

@interface YKRabbitMQSDKDemoViewController ()
///
@property (nonatomic, strong, readwrite) UILabel *navLabel;
///
@property (nonatomic, strong, readwrite) UIScrollView *scrollView;
///
@property (nonatomic, strong, readwrite) UITextView *textView;
///
@property (nonatomic, strong, readwrite) UIButton *backButton;
///
@property (nonatomic, strong, readwrite) UILabel *urlLabel;
@end

@implementation YKRabbitMQSDKDemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupui];
    [self bindData];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    UIEdgeInsets safe = UIEdgeInsetsZero;
    if (@available(iOS 11.0, *)) {
        safe = self.view.safeAreaInsets;
    }
    self.navLabel.frame = CGRectMake(0, safe.top, self.view.bounds.size.width, 44);
    self.textView.frame = CGRectMake(16, CGRectGetMaxY(self.navLabel.frame) + 16, self.view.bounds.size.width - 32, 200);
    self.scrollView.frame = CGRectMake(0, CGRectGetMaxY(self.textView.frame), self.view.bounds.size.width, self.view.frame.size.height - CGRectGetMaxY(self.textView.frame) - safe.bottom);
    
}

#pragma mark -private
- (void)setupui {
    self.view.backgroundColor = UIColor.whiteColor;
    [self.view addSubview:self.navLabel];
    [self.view addSubview:self.textView];
    [self.view addSubview:self.scrollView];
    
}

- (void)bindData {
    
}

#pragma mark -public
+ (void)showInViewController:(UIViewController *)viewController completion:(void (^ __nullable)(void))completion;
{
    YKRabbitMQSDKDemoViewController *vc = [[YKRabbitMQSDKDemoViewController alloc] init];
    [viewController presentViewController:vc animated:YES completion:completion];
}

#pragma mark -get/set
- (UILabel *)navLabel
{
    if (!_navLabel) {
        _navLabel = [[UILabel alloc] init];
        _navLabel.text = @"RabbitMQDemo";
        _navLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _navLabel;
}

- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    }
    return _scrollView;
}

- (UITextView *)textView
{
    if (!_textView) {
        _textView = [[UITextView alloc] initWithFrame:CGRectMake(15, 15, self.view.bounds.size.width - 39, 100)];
        _textView.userInteractionEnabled = NO;
        _textView.layer.cornerRadius = 12;
        _textView.layer.borderColor = UIColor.blackColor.CGColor;
        _textView.layer.borderWidth = 1;
        _textView.clipsToBounds = YES;
    }
    return _textView;
}

- (UILabel *)urlLabel
{
    if (!_urlLabel) {
        _urlLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    }
    return _urlLabel;
}

@end
